import moment from 'moment';

const renderDetailMessageDuration = detailMessage => {
  if (`${detailMessage.sourceType}` === '1') {
    return '不限';
  }

  const startTime = moment(detailMessage.startTime).format(
    "YYYY-MM-DD HH:mm:ss"
  );
  const endTime = moment(detailMessage.endTime).format("YYYY-MM-DD HH:mm:ss");
  if (
    moment(endTime, "YYYY-MM-DD HH:mm:ss").diff(
      moment(startTime, "YYYY-MM-DD HH:mm:ss"),
      "years"
    ) >= 100
  ) {
    return '不限';
  }
  return `${startTime} ~ ${endTime}`;
};

export default renderDetailMessageDuration;